package mytest.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import mytest.util.RequestUtil;
import mytest.util.Response;
import test.testcase.dao.CaseCountDao;
import test.utils.JsonResult;

@Controller @RequestMapping(value = "/tongji", produces = "application/json; charset=utf-8")
@CrossOrigin
public class tongji {

	@RequestMapping(value = "/casecount/{limit}", method = RequestMethod.GET)
	public @ResponseBody String datelist(@PathVariable String limit, HttpServletRequest request) {
		JsonResult response = CaseCountDao.getCaseCountlimit(limit, RequestUtil.getProjectId(request));
		if (response == null) {
			return "";
		}
		return response.toResponse();
	}
	
	@RequestMapping(value = "/all", method = RequestMethod.GET)
	public @ResponseBody String all(HttpServletRequest request) {
		return CaseCountDao.tongji(RequestUtil.getProjectId(request)).toResponse();
	}
	
}
